<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>交大在线服务后台管理系统登录...</title>
<jsp:include page="links.jsp"></jsp:include>
<script type="text/javascript">
	var logindlg;
	var loginForm;
	var regDlg;
	var regForm;
	$(function() {
		logindlg = $('#logindlg').dialog({
			modal : true,
			closable : false,
			iconCls : 'icon-tip',
			buttons : [ {
				text : '注册',
				iconCls : 'icon-edit',
				handler : function() {
					$('#regDlg').dialog('open');
				}
			}, {
				text : '登录',
				iconCls : 'icon-help',
				handler : function() {
					loginForm.submit();
				}
			} ]
		});

		//form 提交
		loginForm = $('#loginForm').form({
			url : 'adminAction/login.do?',
			onSubmit : function() {
				return $(this).form('enableValidation').form('validate');
			},
			success : function(r) {
				//r = eval("(" + r + ")");
				r = $.parseJSON(r);//将标准json转成obj
				if (r && r.success) {
					logindlg.dialog('close');
					location.href = "index.jsp";
				} else {
					$.messager.alert('提示', '用户名密码错误');
					$('#aname').val('');
					$('#apwd').val('');
				}
			}
		});
		//回车换行和提交
		loginForm.find('input').on('keyup', function(event) {
			if (event.keyCode == '13') {
				loginForm.submit();
			}
		});
		//注册对话框
		regDlg = $('#regDlg').dialog({
			title : '用户注册',
			closed : true,
			cache : false,
			iconCls : 'icon-tip',
			modal : true,
			buttons : [ {
				text : '注册',
				handler : function() {
					$('#regForm').submit();
					$('#regDlg').dialog('close');
				}
			}, {
				text : '关闭',
				handler : function() {
					$('#regDlg').dialog('close');
				}
			} ]
		});
		regForm = $('#regForm').form({
			url : 'adminAction/add.do',
			onSubmit : function() {
				if ($('#apwd1').val() == $('#apwd2').val()) {
					return true;
				} else {
					$.messager.alert('提示', '两次密码输入不一致');
					$('#apwd1').val('');
					$('#apwd2').val('');
					return false;
				}
			},
			success : function(r) {
				r = $.parseJSON(r);//将标准json转成obj
				if (r && r.success) {
					$('#regDlg').dialog('close');
					$.messager.show({
						title : '提示',
						msg : '注册成功',
						showType : 'show'
					});
				}
			}
		});
	});
</script>
</head>
<body>
	<div style="text-align: center">
		<h1 style="font-size: 50px;">大连交通大学 在线服务后台管理系统 by SLD</h1>
	</div>

	<div id="logindlg" title="用户登录" style="width: 300px; height: 185px; padding: 22px">
		<form id="loginForm" action="" method="post">
			<table>
				<tr>
					<th>用户名</th>
					<td><input id="aname" class="easyui-validatebox" name="admin.name" type="text"
						data-options="novalidate:true,missingMessage:'请输入用户名'" /></td>
				</tr>
				<tr>
					<th>密码</th>
					<td><input id="apwd" class="easyui-validatebox" name="admin.pwd" type="password"
						data-options="novalidate:true,missingMessage:'请输入密码'" /></td>
				</tr>
			</table>
		</form>
	</div>
	<div id="regDlg" style="width: 300px; height: 200px; padding: 22px">
		<form id="regForm" method="post">
			<table>
				<tr>
					<th>用户名</th>
					<td><input class="easyui-validatebox" type="text" name="admin.name"
						data-options="novalidate:true,missingMessage:'请输入用户名'"></input></td>
				</tr>
				<tr>
					<th>密码</th>
					<td><input id="apwd1" class="easyui-validatebox" name="admin.pwd" type="password"
						data-options="novalidate:true,missingMessage:'请输入密码'" /></td>
				</tr>
				<tr>
					<th>确认密码</th>
					<td><input id="apwd2" class="easyui-validatebox" name="repwd" type="password"
						data-options="novalidate:true,missingMessage:'重复输入密码'" /></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>